{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4.4.单变量非线性变换\n",
    "<P>log和exp函数可以把帮助调节数据的相对比例，从而改进线性模型或神经网络的学习效果。大部分模型在每个特征（回归问题中还包括目标值）大致遵循高斯分布时表现最好,也就是说,每个特征的直方图应该具有类似“钟型曲线”的形状，使用log和exp能较好地变换该种形状</P>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "rnd = np.random.RandomState(0) \n",
    "X_org = rnd.normal(size=(1000,3)) # size表示：指定正态分布的维度(1000行3列)\n",
    "w = rnd.normal(size=3)\n",
    "\n",
    "X=rnd.poisson(10*np.exp(X_org))\n",
    "y=np.dot(X_org,w) #做矩阵乘法 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "特征的前10个元素:\n",
      "[[ 56  18  27]\n",
      " [ 81  57   3]\n",
      " [ 25   9  11]\n",
      " [ 20  13  30]\n",
      " [ 27  13  13]\n",
      " [ 18  46   7]\n",
      " [ 12   3   1]\n",
      " [ 21  20   2]\n",
      " [109   1   6]\n",
      " [  7  55  41]]\n",
      "特征个元素出现的个数:\n",
      "[28 38 68 48 61 59 45 56 37 40 35 34 36 26 23 26 27 21 23 23 18 21 10  9\n",
      " 17  9  7 14 12  7  3  8  4  5  5  3  4  2  4  1  1  3  2  5  3  8  2  5\n",
      "  2  1  2  3  3  2  2  3  3  0  1  2  1  0  0  3  1  0  0  0  1  3  0  1\n",
      "  0  2  0  1  1  0  0  0  0  1  0  0  2  2  0  1  1  0  0  0  0  1  1  0\n",
      "  0  0  0  0  0  0  1  0  0  0  0  0  1  1  0  0  1  0  0  0  0  0  0  0\n",
      "  1  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1]\n"
     ]
    }
   ],
   "source": [
    "# print(X_org)\n",
    "# print(y)\n",
    "print(f\"特征的前10个元素:\\n{X[:10]}\")\n",
    "print(\"特征个元素出现的个数:\\n{}\".format(np.bincount(X[:,0]))) # np.bincount()即统计数值出现次数,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Value')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAWd0lEQVR4nO3dfZBldX3n8fcHBkVRVpBmdgK6o9asD7ECmCmfcF0jkuDjkIq4GM1OEram3NX4kFgJxqrE3dRukVofYq1rLHwcI0EQIYxmYyATXXVVdAZBUSCooI6OzIgPUUw0yHf/OL+WOz23e7pn+ty+Pef9quq65/zO0/feuf3pM797zu+mqpAkDccRK12AJGmyDH5JGhiDX5IGxuCXpIEx+CVpYNasdAGLccIJJ9T69etXugxJWlV27tz57aqamdveW/AneThwyUjTQ4E/At7d2tcDtwHPq6rvLrSv9evXs2PHjn4KlaTDVJKvjmvvraunqm6uqlOr6lTgF4EfAVcA5wPbq2oDsL3NS5ImZFJ9/GcAX66qrwKbgK2tfStw9oRqkCQxueA/F7i4Ta+tqt0A7fHECdUgSWICwZ/kXsBzgPctcbstSXYk2bF3795+ipOkAZrEGf/TgWur6vY2f3uSdQDtcc+4jarqwqraWFUbZ2b2+1BaknSQJhH8z+eebh6AbcDmNr0ZuHICNUiSml6DP8l9gTOBy0eaLwDOTHJLW3ZBnzVIkvbV6w1cVfUj4IFz2u6gu8pHkrQCHLJBkgZmcMGfdD+SNFSDC35JGjqDX5IGxuCXpIEx+CVpYAx+S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ogiSPoxuWeZxxQ90eyCuA2+m+1esIurP8heoap9q236uqU8cs/1/A66tqW5Kn0J3Bzxp9LkcATxj5QwBAC/C5r/8auuc7rqax+wEuSPLXdONHfSrJ06rqpnmek1YR+/g1abfRdbEAPPcg9/EfAJI8ie6LS74P/C3wO22ES5Kctoj9fBQ4O93ImMcAvwp87ADb/Ctgd1XdDfwGXbfOrMemGw32iFbjx1v7EdzzXH8d+Hh137twa5JzWr1JcsrIMb7RpmdHwBznKuAlszPtfyEL2Q48L8kD2/qzn5uM3U+Sh1U3YuSf0g1494gD7F+rhMGvSXst8J+TfIKu//lgfLdt/xa60RcB/oSuG+Zz6b68+k8OtJPqvvbyXXTD214DvK2qFurmAXgzsDnJp+i6eUbPwD8JXEA3yuatwBWt/U7g55PspOtu+W+t/QXAeUmup/t8YfarQV9D1wX0MeDbC9TyUmBj+7D2i8CLDvB8vwD8d+D/tmPODgU+335e3j70vh74J+755iqtco7OKS2D1iXzyqp61phlP6yq+02+Kmk8z/glaWA845ekgfGMX5IGxuCXpIEx+CVpYAx+SRoYg1+SBub/A7aTSSmS3CPSAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "bins = np.bincount(X[:,0])\n",
    "plt.bar(range(len(bins)),bins,color='b')\n",
    "plt.xlabel(\"number of appearences\")\n",
    "plt.ylabel(\"Value\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test score:0.622\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import Ridge\n",
    "from sklearn.model_selection import train_test_split\n",
    "X_train,X_test,y_train,y_test = train_test_split(X,y,random_state=0)\n",
    "score = Ridge().fit(X_train,y_train).score(X_test,y_test)\n",
    "print(\"Test score:{:.3f}\".format(score))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 做对数变换\n",
    "X_train_log = np.log(X_train+1) # 由于初始数据中存在0,0在对数中无意义,所以我们需要对原数据加1\n",
    "X_test_log=np.log(X_test+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 0, 'Value')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEGCAYAAACNaZVuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAWZklEQVR4nO3de7RmdX3f8feHW7gIBcIwHcFxNGWRUiOXHK+0OhFIMBJAUyK00InSjFnVBNJkyWjTWJbtCmkqlSTmMo004yUQBLl4iWE6MlitBWa4w0AGLSIyzoyo4RZB4Ns/nj3hCOeyz5nZzzPn7PdrrbOeZ+9n7/1895o1n7PPb//275eqQpLUL7uMugBJ0vAZ/pLUQ4a/JPWQ4S9JPWT4S1IP7TbqAto46KCDasmSJaMuQ5LmlPXr13+nqhZM9NmcCP8lS5awbt26UZchSXNKkm9M9pnNPpLUQ4a/JPWQ4S9JPWT4S1IPGf6S1EOGvyT1kOEvST1k+EtSDxn+ktRDc+IJX2nU1mbtjLZfWks7qUPaUbzyl6Qe6jT8k/xGkruS3JnkkiR7JjkwyeokG5vXA7qsQZL0Qp2Ff5JDgF8HxqrqFcCuwOnACmBNVR0GrGmWJUlD1HWzz27AXkl2A/YGHgJOAVY1n68CTu24BknS83QW/lX1LeC/AQ8Am4C/q6prgYVVtanZZhNw8ET7J1meZF2SdVu3bu2qTEnqpS6bfQ5gcJX/MuDFwD5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WHw//2LVXXmiMsamiT7NB0cSLIP8LPApL395m34V9XTwLZhJDYAl3U8jMROJcklwFeBw5M8mOTsUdc0RMcCZzG48ru1+fn5URc1JIuA65LczuACaHVV9a7LY08tBL6c5DbgRuBzVfWFyTaet109JUmTm7dX/pKkyRn+ktRDhr8k9ZDhL0k9ZPhLUg8Z/lIjydokP/e8decm+eMptu/lJOGa+wx/6TmXMHg4aLzTm/XSvGL4S8+5HDgpyY/BPwwK92LgXyVZN9X4+EkeG/f+Xyb5i+b9giRXJLmp+Tm265OQ2jD8pUZVPczgychtY+GcDvwV8B+qagx4JfDGJK+cwWEvAv57Vb0K+EUcalg7id1GXYC0k9nW9HN18/pO4Jea4XF3YzB8whHA7S2PdzxwxGC4IQD2S7JvM8+ANDKGv/SjrgIuTHIMsBfwPeC3gFdV1fea5pw9J9hv/Dgp4z/fBXhdVf19R/VKs2KzjzROMwvWWuBiBn8F7Ac8DvxdkoUMxkmfyOYk/zTJLsBbx62/lsEAgwAkOaqLuqWZMvylF7oEOBK4tKpuA24B7mLwC+Erk+yzAvgs8EVg07j1vw6MJbk9yd3Ar3ZWtTQDjuopST3klb8k9ZDhL0k9ZPhLUg8Z/pLUQ4a/JPWQ4S9JPWT4S1IP/X9msxJM5G+0iAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.hist(X_train_log[:,0],bins=25,color='m')\n",
    "plt.ylabel(\"Number of apperances\")\n",
    "plt.xlabel(\"Value\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test score:0.875\n"
     ]
    }
   ],
   "source": [
    "score = Ridge().fit(X_train_log,y_train).score(X_test_log,y_test)\n",
    "print(\"Test score:{:.3f}\".format(score))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
